<?php
//活动表

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Casts\Attribute;

class FollowRatePerDateModel extends Model
{
    use HasFactory, SoftDeletes;
    protected $table = 'follow_rate_per_day';


    // 访问器
    protected function highestPrice(): Attribute
    {
        return new Attribute(
            get: fn ($value) => round($value / 100, 2),
            set: fn ($value) => $value * 100,
        );
    }

    protected function lowestPrice(): Attribute
    {
        return new Attribute(
            get: fn ($value) => round($value / 100, 2),
            set: fn ($value) => $value * 100,
        );
    }

    protected function highestRate(): Attribute
    {
        return new Attribute(
            get: fn ($value) => round($value / 100, 2),
            set: fn ($value) => $value * 10000,
        );
    }

    protected function lowestRate(): Attribute
    {
        return new Attribute(
            get: fn ($value) => round($value / 100, 2),
            set: fn ($value) => $value * 10000,
        );
    }
}
